<!DOCTYPE html>
<html>

<head>
    <title>v-on绑定事件实例</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0 " />
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>

<body>
    <h1>v-on绑定事件实例</h1>
    <hr>
    <div id="app">
        本场比赛的分：{{number}}
        <p>
            <button v-on:click='addnumber'>加分</button>
            <button @click='jiannumber'>减分</button><br/>
            <input type="text" v-on:keyup.enter="onEnter" v-model="number2">
        </p>
    </div>
    <script type="text/javascript">
        var app = new Vue({
            el: '#app',
            data: {
                number: 0,
                number2: 1
            },
            methods: {
                addnumber: function() {
                    this.number++;
                },
                jiannumber: function() {
                    this.number--;
                },
                onEnter: function() {
                    this.number = this.number + parseInt(this.number2)
                }
            }

        })
    </script>
</body>

</html>